<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018-10-16
 * Time: 14:38
 */
namespace app\api\model;
use think\Db;
use think\Request;

class Login
{
    /***
     * 检测是否存在此token，如果存在返回该用户信息
     * @param $token
     * @return array|bool|null|\PDOStatement|string|\think\Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static public function index($token)
    {
        $user = Db::view("user")
            ->view('vip_price','vip_icon,vip_name','vip_price.id=user.vip','left')
            ->view('occupation','occupation_name','occupation.id=user.occupation','left')
            ->where("token",$token)
            ->json(['answer_number'])
            ->find();
        if($user){
            return $user;
        }else{
            return false;
        }
    }

}